Skip to content

Use nested type docstrings as default helptext for argument groups - #485

Open
brentyi wants to merge 2 commits into
mainfrom
brent/20260728_nested_docstring_group_help
Open

Use nested type docstrings as default helptext for argument groups#485
brentyi wants to merge 2 commits into
mainfrom
brent/20260728_nested_docstring_group_help

Conversation

@brentyi

@brentyi brentyi commented Jul 28, 2026

Copy link
Copy Markdown
Owner

Use the class docstring of nested types as the default argument group description, fixing the unreachable docstring fallback described in #483.

)

The docstring fallback for group descriptions existed but was unreachable:
field helptext is stored as a lazy callable for deferred docstring parsing,
so it was never None even when evaluation would return None. Evaluate
lazily and fall back to the nested type's class docstring only when the
field has no attribute docstring or explicit help. An explicit
tyro.conf.arg(help="") still suppresses the group description.
@codecov

codecov Bot commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.79%. Comparing base (d0f2e3f) to head (c6939ff).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #485   +/-   ##
=======================================
  Coverage   99.79%   99.79%           
=======================================
  Files          53       53           
  Lines        4495     4495           
=======================================
  Hits         4486     4486           
  Misses          9        9           
Flag Coverage Δ
unittests 99.79% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Python 3.8 resolves class source code by scanning for the first matching
class name in the file, so tests that reuse local class names can pick up
the wrong attribute docstrings. This broke the docstring precedence test
on 3.8 only.

brentyi commented Jul 29, 2026

Copy link
Copy Markdown
Owner Author

Status: the pytest (3.8) failure was real and is fixed in c6939ff (Python 3.8 resolves class source by scanning for the first matching class name in the file, so the new tests needed unique local class names).

The remaining ruff, mypy, and ty failures are pre-existing on main: CI runs unpinned latest linters, and all flagged locations are in files this PR does not touch. I verified locally that unmodified main fails ruff 0.16.0 with the same 18 PLR0917 errors (PLR0917 was stabilized in 0.16.0; mypy and ty failures are similar version drift in test_bug_repros.py and test_unsupported_but_should_work.py). Fixing or pinning those seems best done in a separate change.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant